﻿using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Text;
using System.Threading.Tasks;
using static DataTurnClient.Enum.DType;

namespace DataTurnClient.ViewModel
{
    public class JobViewModel : ReactiveObject
    {
        public ViewModelActivator Activator { get; }

        public IScheduler MainScheduler;

        #region 属性
        public Job Job
        {
            get => _Job;
            set => this.RaiseAndSetIfChanged(ref _Job, value);
        }
        private Job _Job = new Job();

        public ControlType ControlStatus 
        {
            get => _ControlStatus;
            set => this.RaiseAndSetIfChanged(ref _ControlStatus, value);
        }
        private ControlType _ControlStatus;
        public bool IsRead
        {
            get => _IsRead;
            set => this.RaiseAndSetIfChanged(ref _IsRead, value);
        }
        private bool _IsRead ;

        public string ErrorMessage
        {
            get => _ErrorMessage;
            set => this.RaiseAndSetIfChanged(ref _ErrorMessage, value);
        }
        private string _ErrorMessage;

        public List<string> WeekList { get; set; } = new List<string>() 
        {
            "周日",
            "周一",
            "周二",
            "周三",
            "周四",
            "周五",
            "周六",
        };

        public List<string> Weeks 
        {
            get
            {
                if (Job.JobWeek != null && Job.JobWeek != "")
                {
                    List<string> week = Job.JobWeek.Split(',').ToList();
                    week.ForEach(x =>
                    {
                        _Weeks.Add(WeekList[Convert.ToInt32(x)]);
                    });
                }
                return _Weeks;
            }
            set
            {
                _Weeks = value;
            }
        }
        private List<string> _Weeks = new List<string>();


        public List<string> RequestMode { get; set; } = new List<string>()
        {
            "Get",
            "Post"
        };
        #endregion
        public JobViewModel()
        {
            Activator = new ViewModelActivator();

        }
    }
}
